class People {
  constructor(name) {
    this.name = name;
  }
  eat() {
    console.log(`${this.name} eating`);
  }
}
class Student extends People {
  constructor(name, number) {
    // this.name = name;
    super(name);
    this.number = number;
  }
  xuexi() {
    console.log(`俺是一个学生，姓名： ${this.name},学号: ${this.number}`);
  }
}

class Teacher extends People {
  constructor(name, major) {
    super(name);
    this.major = major;
  }
  teach() {
    console.log(`老师：俺是${this.name}:教的是${this.major}`);
  }
}

// 创建一个实例
const xiaLuo = new Student("夏洛te", 100);
console.log(xiaLuo);
console.log(xiaLuo.name);
console.log(xiaLuo.number);
// console.log(xiaLuo.eat());
console.log(xiaLuo.xuexi());

const wang = new Teacher("王老师", "语文");
console.log(wang);
console.log(wang.name);
console.log(wang.major);
console.log(wang.eat());
console.log(wang.teach());

// class 实际上是函数
console.log("typeof People:", typeof People); // function
console.log("typeof Student:", typeof Student); // function

// 隐式类型 和显示类型
console.log(xiaLuo.__proto__);
console.log(Student.prototype);
console.log(Student.prototype === xiaLuo.__proto__);
